New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

as-uuid

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-uuid

AssemblyScript library to generate RFC-compliant UUIDs v4 (random)

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42
decreased by-64.41%
Maintainers
1
Weekly downloads
 
Created
Source

as-uuid

AssemblyScript library to generate RFC-compliant UUIDs v4 (random) 🚀

Install

npm install --save as-uuid

Use

Generate a random UUID string:

import uuid from "as-uuid";

const id: string = uuid();  

id; // "0f5abcd1-c194-47f3-905b-2df7263a084b"

Using NativeMath

The library use Math.random by default to generate random numbers.

This requires a seed for the random number generator to be imported from the host:

WebAssembly.instantiateStreaming(fetch('my.wasm'), {
  env: {
    seed: Date.now,
    // ...
  }
});

Notice that the seed is provided automatically when the loader is used or when WASI is imported.

More details at https://www.assemblyscript.org/stdlib/math.html#using-nativemath

Using WASI

Alternatively, WASI can be used to import the random number generator:

import uuid from "as-uuid/uuid-wasi";

const id: string = uuid();  

id; // "0f5abcd1-c194-47f3-905b-2df7263a084b"
WebAssembly.instantiateStreaming(fetch('my.wasm'), {
  wasi_snapshot_preview1: // ...
});

Build

The assembly directory contains AS source code.

npm i
npm run asbuild

Test

The assembly/__tests__ directory contains all unit tests.

npm test
npm run test:wasi

Licence

MIT

Keywords

FAQs

Package last updated on 30 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc